From 8a8ea1e89ee8bc1ddb76c05f3d11c40015b0adeb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 18 May 2015 15:57:17 -0700 Subject: [PATCH] Add rustc/rustdoc config keys to Cargo config In addition to global RUSTC/RUSTDOC env vars, this commit recognizes `build.rustc` and `build.rustdoc` as configuration keys for Cargo to instruct what tools should be used instead of the default. Closes #967 --- src/cargo/ops/cargo_compile.rs | 24 +++++++----- src/cargo/ops/cargo_rustc/compilation.rs | 13 ++++--- src/cargo/ops/cargo_rustc/context.rs | 27 ++++++------- src/cargo/ops/cargo_rustc/engine.rs | 10 +++-- src/cargo/ops/cargo_rustc/fingerprint.rs | 22 +++++------ src/cargo/ops/cargo_rustc/mod.rs | 42 ++++++++++----------- src/cargo/ops/cargo_test.rs | 8 ++-- src/cargo/util/config.rs | 48 +++++++++++++++++------- src/cargo/util/mod.rs | 2 +- src/doc/config.md | 4 +- tests/test_bad_config.rs | 10 +---- tests/test_cargo_compile.rs | 6 +-- tests/test_cargo_compile_custom_build.rs | 12 +++--- tests/test_cargo_compile_plugins.rs | 2 +- tests/test_cargo_cross_compile.rs | 3 +- tests/tests.rs | 4 ++ 16 files changed, 133 insertions(+), 104 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 74137e9ef..26db527dc 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -82,9 +82,9 @@ pub enum CompileFilter<'a> { } } -pub fn compile(manifest_path: &Path, - options: &CompileOptions) - -> CargoResult { +pub fn compile<'a>(manifest_path: &Path, + options: &CompileOptions<'a>) + -> CargoResult> { debug!("compile; manifest-path={}", manifest_path.display()); let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), @@ -101,8 +101,9 @@ pub fn compile(manifest_path: &Path, compile_pkg(&package, options) } -pub fn compile_pkg(package: &Package, options: &CompileOptions) - -> CargoResult { +pub fn compile_pkg<'a>(package: &Package, + options: &CompileOptions<'a>) + -> CargoResult> { let CompileOptions { config, jobs, target, spec, features, no_default_features, release, mode, ref filter, ref exec_engine, @@ -174,10 +175,12 @@ pub fn compile_pkg(package: &Package, options: &CompileOptions) profile.rustc_args = Some(args.to_vec()); Some((target, profile)) } - Some(_) => - return Err(human("extra arguments to `rustc` can only be passed to one target, \ - consider filtering\nthe package by passing e.g. `--lib` or \ - `--bin NAME` to specify a single target")), + Some(_) => { + return Err(human("extra arguments to `rustc` can only be passed to \ + one target, consider filtering\nthe package by \ + passing e.g. `--lib` or `--bin NAME` to specify \ + a single target")) + } None => None, }; @@ -195,7 +198,8 @@ pub fn compile_pkg(package: &Package, options: &CompileOptions) try!(ops::compile_targets(&targets, to_build, &PackageSet::new(&packages), - &resolve_with_overrides, &sources, + &resolve_with_overrides, + &sources, config, build_config, to_build.manifest().profiles())) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 302e6fd9e..bd6be3c4c 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -4,12 +4,12 @@ use std::path::PathBuf; use semver::Version; use core::{PackageId, Package, Target}; -use util::{self, CargoResult}; +use util::{self, CargoResult, Config}; use super::{CommandType, CommandPrototype}; /// A structure returning the result of a compilation. -pub struct Compilation { +pub struct Compilation<'cfg> { /// All libraries which were built for a package. /// /// This is currently used for passing --extern flags to rustdoc tests later @@ -44,10 +44,12 @@ pub struct Compilation { /// Features enabled during this compilation. pub features: HashSet, + + config: &'cfg Config, } -impl Compilation { - pub fn new(pkg: &Package) -> Compilation { +impl<'cfg> Compilation<'cfg> { + pub fn new(pkg: &Package, config: &'cfg Config) -> Compilation<'cfg> { Compilation { libraries: HashMap::new(), native_dirs: HashMap::new(), // TODO: deprecated, remove @@ -58,6 +60,7 @@ impl Compilation { extra_env: HashMap::new(), package: pkg.clone(), features: HashSet::new(), + config: config, } } @@ -98,7 +101,7 @@ impl Compilation { search_path.push(self.deps_output.clone()); let search_path = try!(util::join_paths(&search_path, util::dylib_path_envvar())); - let mut cmd = try!(CommandPrototype::new(cmd)); + let mut cmd = try!(CommandPrototype::new(cmd, self.config)); cmd.env(util::dylib_path_envvar(), &search_path); for (k, v) in self.extra_env.iter() { cmd.env(k, v); diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 3abb93e09..2fcde4398 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -25,11 +25,11 @@ pub enum Platform { PluginAndTarget, } -pub struct Context<'a> { - pub config: &'a Config, +pub struct Context<'a, 'cfg: 'a> { + pub config: &'cfg Config, pub resolve: &'a Resolve, - pub sources: &'a SourceMap<'a>, - pub compilation: Compilation, + pub sources: &'a SourceMap<'cfg>, + pub compilation: Compilation<'cfg>, pub build_state: Arc, pub exec_engine: Arc>, pub fingerprints: HashMap<(&'a PackageId, &'a Target, &'a Profile, Kind), @@ -49,23 +49,24 @@ pub struct Context<'a> { profiles: &'a Profiles, } -impl<'a> Context<'a> { +impl<'a, 'cfg> Context<'a, 'cfg> { pub fn new(resolve: &'a Resolve, - sources: &'a SourceMap<'a>, + sources: &'a SourceMap<'cfg>, deps: &'a PackageSet, - config: &'a Config, + config: &'cfg Config, host: Layout, target_layout: Option, root_pkg: &Package, build_config: BuildConfig, - profiles: &'a Profiles) -> CargoResult> { + profiles: &'a Profiles) -> CargoResult> { let target = build_config.requested_target.clone(); let target = target.as_ref().map(|s| &s[..]); - let (target_dylib, target_exe) = try!(Context::filename_parts(target)); + let (target_dylib, target_exe) = try!(Context::filename_parts(target, + config)); let (host_dylib, host_exe) = if build_config.requested_target.is_none() { (target_dylib.clone(), target_exe.clone()) } else { - try!(Context::filename_parts(None)) + try!(Context::filename_parts(None, config)) }; let target_triple = target.unwrap_or(config.rustc_host()).to_string(); let engine = build_config.exec_engine.as_ref().cloned().unwrap_or({ @@ -84,7 +85,7 @@ impl<'a> Context<'a> { host_dylib: host_dylib, host_exe: host_exe, requirements: HashMap::new(), - compilation: Compilation::new(root_pkg), + compilation: Compilation::new(root_pkg, config), build_state: Arc::new(BuildState::new(&build_config, deps)), build_config: build_config, exec_engine: engine, @@ -96,9 +97,9 @@ impl<'a> Context<'a> { /// Run `rustc` to discover the dylib prefix/suffix for the target /// specified as well as the exe suffix - fn filename_parts(target: Option<&str>) + fn filename_parts(target: Option<&str>, cfg: &Config) -> CargoResult<(Option<(String, String)>, String)> { - let mut process = try!(util::process(util::rustc())); + let mut process = try!(util::process(cfg.rustc())); process.arg("-") .arg("--crate-name").arg("_") .arg("--crate-type").arg("dylib") diff --git a/src/cargo/ops/cargo_rustc/engine.rs b/src/cargo/ops/cargo_rustc/engine.rs index 3d3a17d8b..41a3188bb 100644 --- a/src/cargo/ops/cargo_rustc/engine.rs +++ b/src/cargo/ops/cargo_rustc/engine.rs @@ -4,7 +4,8 @@ use std::fmt; use std::path::Path; use std::process::Output; -use util::{self, CargoResult, ProcessError, ProcessBuilder, process}; +use util::{CargoResult, ProcessError, ProcessBuilder, process}; +use util::Config; /// Trait for objects that can execute commands. pub trait ExecEngine: Send + Sync { @@ -35,11 +36,12 @@ pub struct CommandPrototype { } impl CommandPrototype { - pub fn new(ty: CommandType) -> CargoResult { + pub fn new(ty: CommandType, config: &Config) + -> CargoResult { Ok(CommandPrototype { builder: try!(match ty { - CommandType::Rustc => process(util::rustc()), - CommandType::Rustdoc => process(util::rustdoc()), + CommandType::Rustc => process(config.rustc()), + CommandType::Rustdoc => process(config.rustdoc()), CommandType::Target(ref s) | CommandType::Host(ref s) => process(s), }), diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index c73118490..bbcb513eb 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -39,11 +39,11 @@ pub type Preparation = (Freshness, Work, Work); /// This function will calculate the fingerprint for a target and prepare the /// work necessary to either write the fingerprint or copy over all fresh files /// from the old directories to their new locations. -pub fn prepare_target<'a>(cx: &mut Context<'a>, - pkg: &'a Package, - target: &'a Target, - profile: &'a Profile, - kind: Kind) -> CargoResult { +pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, + pkg: &'a Package, + target: &'a Target, + profile: &'a Profile, + kind: Kind) -> CargoResult { let _p = profile::start(format!("fingerprint: {} / {}", pkg.package_id(), target.name())); let new = dir(cx, pkg, kind); @@ -131,12 +131,12 @@ impl Fingerprint { /// /// Information like file modification time is only calculated for path /// dependencies and is calculated in `calculate_target_fresh`. -fn calculate<'a>(cx: &mut Context<'a>, - pkg: &'a Package, - target: &'a Target, - profile: &'a Profile, - kind: Kind) - -> CargoResult { +fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, + pkg: &'a Package, + target: &'a Target, + profile: &'a Profile, + kind: Kind) + -> CargoResult { let key = (pkg.package_id(), target, profile, kind); match cx.fingerprints.get(&key) { Some(s) => return Ok(s.clone()), diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 24f160393..aebd03410 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -3,7 +3,7 @@ use std::env; use std::ffi::OsString; use std::fs; use std::io::prelude::*; -use std::path::{self, PathBuf}; +use std::path::{self, Path, PathBuf}; use std::sync::Arc; use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve}; @@ -56,8 +56,8 @@ pub struct TargetConfig { /// /// The second element of the tuple returned is the target triple that rustc /// is a host for. -pub fn rustc_version() -> CargoResult<(String, String)> { - let output = try!(try!(util::process(util::rustc())) +pub fn rustc_version>(rustc: P) -> CargoResult<(String, String)> { + let output = try!(try!(util::process(rustc.as_ref())) .arg("-vV") .exec_with_output()); let output = try!(String::from_utf8(output.stdout).map_err(|_| { @@ -77,17 +77,17 @@ pub fn rustc_version() -> CargoResult<(String, String)> { // Returns a mapping of the root package plus its immediate dependencies to // where the compiled libraries are all located. -pub fn compile_targets<'a>(targets: &[(&'a Target, &'a Profile)], - pkg: &'a Package, - deps: &PackageSet, - resolve: &'a Resolve, - sources: &'a SourceMap<'a>, - config: &'a Config, - build_config: BuildConfig, - profiles: &'a Profiles) - -> CargoResult { +pub fn compile_targets<'a, 'cfg: 'a>(targets: &[(&'a Target, &'a Profile)], + pkg: &'a Package, + deps: &'a PackageSet, + resolve: &'a Resolve, + sources: &'a SourceMap<'cfg>, + config: &'cfg Config, + build_config: BuildConfig, + profiles: &'a Profiles) + -> CargoResult> { if targets.is_empty() { - return Ok(Compilation::new(pkg)) + return Ok(Compilation::new(pkg, config)) } debug!("compile_targets: {}", pkg); @@ -181,10 +181,10 @@ pub fn compile_targets<'a>(targets: &[(&'a Target, &'a Profile)], Ok(cx.compilation) } -fn compile<'a>(targets: &[(&'a Target, &'a Profile)], - pkg: &'a Package, - cx: &mut Context<'a>, - jobs: &mut JobQueue<'a>) -> CargoResult<()> { +fn compile<'a, 'cfg>(targets: &[(&'a Target, &'a Profile)], + pkg: &'a Package, + cx: &mut Context<'a, 'cfg>, + jobs: &mut JobQueue<'a>) -> CargoResult<()> { debug!("compile_pkg; pkg={}", pkg); let profiling_marker = profile::start(format!("preparing: {}", pkg)); @@ -292,10 +292,10 @@ fn compile<'a>(targets: &[(&'a Target, &'a Profile)], Ok(()) } -fn prepare_init<'a>(cx: &mut Context<'a>, - pkg: &'a Package, - jobs: &mut JobQueue<'a>, - visited: &mut HashSet<&'a PackageId>) { +fn prepare_init<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, + pkg: &'a Package, + jobs: &mut JobQueue<'a>, + visited: &mut HashSet<&'a PackageId>) { if !visited.insert(pkg.package_id()) { return } // Set up all dependencies diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 360d1b7d4..631ffae52 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -101,10 +101,10 @@ pub fn run_benches(manifest_path: &Path, Ok(try!(build_and_run(manifest_path, options, &args)).err()) } -fn build_and_run(manifest_path: &Path, - options: &TestOptions, - test_args: &[String]) - -> CargoResult> { +fn build_and_run<'a>(manifest_path: &Path, + options: &TestOptions<'a>, + test_args: &[String]) + -> CargoResult, ProcessError>> { let config = options.compile_opts.config; let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(), config)); diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index af567da54..65f119bae 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -2,6 +2,7 @@ use std::cell::{RefCell, RefMut, Ref, Cell}; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::hash_map::{HashMap}; use std::env; +use std::ffi::OsString; use std::fmt; use std::fs::{self, File}; use std::io::prelude::*; @@ -27,6 +28,8 @@ pub struct Config { values: RefCell>, values_loaded: Cell, cwd: PathBuf, + rustc: PathBuf, + rustdoc: PathBuf, } impl Config { @@ -34,20 +37,29 @@ impl Config { let cwd = try!(env::current_dir().chain_error(|| { human("couldn't get the current directory of the process") })); - let (rustc_version, rustc_host) = try!(ops::rustc_version()); - Ok(Config { + let mut cfg = Config { home_path: try!(homedir().chain_error(|| { human("Cargo couldn't find your home directory. \ This probably means that $HOME was not set.") })), shell: RefCell::new(shell), - rustc_version: rustc_version, - rustc_host: rustc_host, + rustc_version: String::new(), + rustc_host: String::new(), cwd: cwd, values: RefCell::new(HashMap::new()), values_loaded: Cell::new(false), - }) + rustc: PathBuf::from("rustc"), + rustdoc: PathBuf::from("rustdoc"), + }; + + cfg.rustc = try!(cfg.get_tool("rustc")); + cfg.rustdoc = try!(cfg.get_tool("rustdoc")); + let (rustc_version, rustc_host) = try!(ops::rustc_version(cfg.rustc())); + cfg.rustc_version = rustc_version; + cfg.rustc_host = rustc_host; + + Ok(cfg) } pub fn home(&self) -> &Path { &self.home_path } @@ -76,6 +88,10 @@ impl Config { self.shell.borrow_mut() } + pub fn rustc(&self) -> &Path { &self.rustc } + + pub fn rustdoc(&self) -> &Path { &self.rustdoc } + /// Return the output of `rustc -v verbose` pub fn rustc_version(&self) -> &str { &self.rustc_version } @@ -189,6 +205,20 @@ impl Config { }; Ok(()) } + + fn get_tool(&self, tool: &str) -> CargoResult { + let var = format!("build.{}", tool); + if let Some((tool, path)) = try!(self.get_string(&var)) { + if tool.contains("/") || (cfg!(windows) && tool.contains("\\")) { + return Ok(path.join(tool)) + } + return Ok(PathBuf::from(tool)) + } + + let var = tool.chars().flat_map(|c| c.to_uppercase()).collect::(); + let tool = env::var_os(&var).unwrap_or_else(|| OsString::from(tool)); + Ok(PathBuf::from(tool)) + } } #[derive(Eq, PartialEq, Clone, RustcEncodable, RustcDecodable, Copy)] @@ -394,14 +424,6 @@ fn homedir() -> Option { return cargo_home.or(user_home); } -pub fn rustc() -> String { - env::var("RUSTC").unwrap_or_else(|_| "rustc".to_string()) -} - -pub fn rustdoc() -> String { - env::var("RUSTDOC").unwrap_or_else(|_| "rustdoc".to_string()) -} - fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> where F: FnMut(File, &Path) -> CargoResult<()> { diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index ea71ae780..e29fa5844 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -1,4 +1,4 @@ -pub use self::config::{Config, rustc, rustdoc}; +pub use self::config::Config; pub use self::process_builder::{process, ProcessBuilder}; pub use self::errors::{CargoResult, CargoError, ChainError, CliResult}; pub use self::errors::{CliError, ProcessError}; diff --git a/src/doc/config.md b/src/doc/config.md index 32b6d3d51..3261e5cde 100644 --- a/src/doc/config.md +++ b/src/doc/config.md @@ -76,7 +76,9 @@ proxy = "..." # HTTP proxy to use for HTTP requests (defaults to none) timeout = 60000 # Timeout for each HTTP request, in milliseconds [build] -jobs = 1 # number of jobs to run by default (default to # cpus) +jobs = 1 # number of jobs to run by default (default to # cpus) +rustc = "rustc" # path to the compiler to execute +rustdoc = "rustdoc" # path to the doc generator to execute ``` # Environment Variables diff --git a/tests/test_bad_config.rs b/tests/test_bad_config.rs index 526245c81..c76d505bd 100644 --- a/tests/test_bad_config.rs +++ b/tests/test_bad_config.rs @@ -102,10 +102,7 @@ test!(bad5 { assert_that(foo.cargo("new") .arg("-v").arg("foo").cwd(&foo.root().join("foo")), execs().with_status(101).with_stderr("\ -Failed to create project `foo` at `[..]` - -Caused by: - Couldn't load Cargo configuration +Couldn't load Cargo configuration Caused by: failed to merge key `foo` between files: @@ -186,10 +183,7 @@ test!(invalid_global_config { assert_that(foo.cargo_process("build").arg("-v"), execs().with_status(101).with_stderr("\ -failed to parse manifest at `[..]Cargo.toml` - -Caused by: - Couldn't load Cargo configuration +Couldn't load Cargo configuration Caused by: could not parse TOML configuration in `[..]config` diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 0a50d770e..cc17a8c65 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -9,7 +9,6 @@ use support::{COMPILING, RUNNING, ProjectBuilder}; use hamcrest::{assert_that, existing_file, is_not}; use support::paths::CargoPathExt; use cargo::util::process; -use cargo::ops::rustc_version; fn setup() { } @@ -1449,7 +1448,7 @@ Caused by: }); test!(cargo_platform_specific_dependency { - let (_, host) = rustc_version().unwrap(); + let host = ::rustc_host(); let p = project("foo") .file("Cargo.toml", &format!(r#" [project] @@ -1776,8 +1775,7 @@ test!(rustc_env_var { Could not execute process `rustc-that-does-not-exist -vV` ([..]) Caused by: -[..] -")); +[..]".to_string() + if cfg!(windows) {"\n[..]\n"} else {"\n"})); assert_that(&p.bin("a"), is_not(existing_file())); }); diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index 65173c83b..8b1061633 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -251,7 +251,7 @@ linked to by one package }); test!(overrides_and_links { - let (_, target) = ::cargo::ops::rustc_version().unwrap(); + let target = ::rustc_host(); let p = project("foo") .file("Cargo.toml", r#" @@ -302,7 +302,7 @@ test!(overrides_and_links { }); test!(unused_overrides { - let (_, target) = ::cargo::ops::rustc_version().unwrap(); + let target = ::rustc_host(); let p = project("foo") .file("Cargo.toml", r#" @@ -521,7 +521,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured }); test!(propagation_of_l_flags { - let (_, target) = ::cargo::ops::rustc_version().unwrap(); + let target = ::rustc_host(); let p = project("foo") .file("Cargo.toml", r#" [project] @@ -579,7 +579,7 @@ test!(propagation_of_l_flags { }); test!(propagation_of_l_flags_new { - let (_, target) = ::cargo::ops::rustc_version().unwrap(); + let target = ::rustc_host(); let p = project("foo") .file("Cargo.toml", r#" [project] @@ -673,7 +673,7 @@ test!(build_deps_simple { }); test!(build_deps_not_for_normal { - let (_, target) = ::cargo::ops::rustc_version().unwrap(); + let target = ::rustc_host(); let p = project("foo") .file("Cargo.toml", r#" [project] @@ -1276,7 +1276,7 @@ test!(cfg_feedback { }); test!(cfg_override { - let (_, target) = ::cargo::ops::rustc_version().unwrap(); + let target = ::rustc_host(); let p = project("foo") .file("Cargo.toml", r#" diff --git a/tests/test_cargo_compile_plugins.rs b/tests/test_cargo_compile_plugins.rs index 3417d01e6..434ffd676 100644 --- a/tests/test_cargo_compile_plugins.rs +++ b/tests/test_cargo_compile_plugins.rs @@ -223,7 +223,7 @@ test!(doctest_a_plugin { // See #1515 test!(native_plugin_dependency_with_custom_ar_linker { - let (_, target) = ::cargo::ops::rustc_version().unwrap(); + let target = ::rustc_host(); let foo = project("foo") .file("Cargo.toml", r#" diff --git a/tests/test_cargo_cross_compile.rs b/tests/test_cargo_cross_compile.rs index a650ec1b1..57bdd59fa 100644 --- a/tests/test_cargo_cross_compile.rs +++ b/tests/test_cargo_cross_compile.rs @@ -4,7 +4,6 @@ use support::{project, execs, basic_bin_manifest}; use support::{RUNNING, COMPILING, DOCTEST}; use hamcrest::{assert_that, existing_file}; use cargo::util::process; -use cargo::ops::rustc_version; fn setup() { } @@ -491,7 +490,7 @@ test!(build_script_needed_for_host_and_target { if disabled() { return } let target = alternate(); - let (_, host) = rustc_version().unwrap(); + let host = ::rustc_host(); let p = project("foo") .file("Cargo.toml", r#" [package] diff --git a/tests/tests.rs b/tests/tests.rs index 1b72798f0..59b5b4c58 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -54,3 +54,7 @@ mod test_cargo_search; mod test_cargo_test; mod test_cargo_version; mod test_shell; + +fn rustc_host() -> String { + cargo::ops::rustc_version("rustc").unwrap().1 +} -- 2.30.2